<? 
	require("required/dbconnect.php"); 
	require("required/function.php"); 
	require("required/header.php");
	
	
	$gift_id=$_GET['gift_id'];
	
				
	if(empty($_GET['product_type']))
	{
		$product_type="product";
		$title="Product";
		checkAccess("allow_product_add",1);
	}
	else
	{
		$product_type=$_GET['product_type'];
		
		switch($product_type)
		{
			case "product":
				checkAccess("allow_product_add",1);
				$title="Product";
				break;
			case "gift";
				checkAccess("allow_gift_management",1);
				$title="Gift";
				break;
			default:
				checkAccess("allow_product_add",1);
				$title="Product";
				break;
		}
	}
?>
				<script language="javascript">
				
					function checkExist(field,divName,showName) {
						var value = document.getElementById(field).value;
						if(value!=""){
							
							changeContent('required/js/checkExist.php?field='+field+'&value='+value+'&showName='+showName,divName)
						}
					}
	
					function getSubCat(catId) 
					{		
						changeContent("required/js/getsubcat.php?catid="+catId,"divSubcat")
					}
					
					function validatefrm(frm1)
					{
						if(document.frm1.cat_id.value=="")
						{
							alert("Please select main category");
							document.frm1.cat_id.focus();
							return false;
						}
						if(document.frm1.sub_cat.value=="")
						{
							alert("Please select sub category");
							document.frm1.sub_cat.focus();
							return false;
						}
						if(document.frm1.product_name_eng.value=="")
						{
							alert("Please enter product name");
							document.frm1.product_name_eng.focus();
							return false;
						}
						if(document.frm1.product_code.value=="")
						{
							alert("Please enter product code");
							document.frm1.product_code.focus();
							return false;
						}
						
						return true;
					
					}
				</script>
				<table width="100%"  cellpadding="5" cellspacing="0" height="300">
				
				<script language="JavaScript" type="text/javascript" src="required/js/goAjax.js"></script>
					
					<td width="100%" align="left" valign="top">
						<form action="product_add2.php" name="frm1" method="post" onSubmit="return validatefrm(this)" enctype="multipart/form-data">
						<table width="100%">
						<td class="title" colspan="2"><strong>Add Gift Item</strong></td>
						
						<?
							$get_cat=mysql_query("select * from os_category order by id asc");
						
						?>
						<tr>
							<Td width="13%">Main Category</Td>
							<td width="87%">
								<select name="cat_id" class="text" onChange="getSubCat(this.value)">
									<option value="">Please Select</option>
									<?
                                        while($c=mysql_fetch_array($get_cat,MYSQL_ASSOC))
                                        {
                                    ?>
                                        <option value="<?= $c['id'] ?>"><?= $c['name_eng'] ?></option>
                                    <? } ?>
								</select>
								
							</td>
						</tr>
						<tr>
							<td>Sub Category</td><td>
							<div id="divSubcat">
								<select name="sub_cat" class="text">
									<option value="">Please Select main category</option>
								</select>						
							</div>
							</td>
						</tr>
                        <tr>
							<td>Products</td><td>
							<div id="divSubcat">
								<select name="sub_cat" class="text">
									<option value="">Please Select main category</option>
								</select>						
							</div>
							</td>
						</tr>
						
						<tr>
							<td colspan="2">
                          
                            <input type="submit" value="Submit" name="btnsubmit"></td>
						</tr>
						</table>
						</form>
					</td>
				 
				</table>
<? require("required/footer.php"); ?>